import { ref, reactive } from 'vue'
import { useStore } from 'vuex'
import { getCorpPartner } from '@/api/corppartner/index'

export default function (query) {
    const store = useStore()
    const queryList = reactive({
        corpid: store.getters.corpinfo.corpid,
        pagesize: 1000
    })
    const resultQueryList = Object.assign(queryList, query)

    const corpPartnerKeyValue = reactive({})
    const corpPartnerList = ref([])

    getCorpPartner(resultQueryList).then(response => {
        if (response.errcode == 0 && response.data.list.length > 0) {
            corpPartnerList.value = response.data.list
            response.data.list.forEach(function (v) {
                corpPartnerKeyValue[v.corpid] = v.corpname
            })
        } else {
            console.log(response)
        }
    })
    return {
        corpPartnerKeyValue,
        corpPartnerList
    }
}
